import { uuid2 } from '../src/utils/auth'

const tokens = {
	admin: {
		token: uuid2()
	}
}

export default {
    login: config => {
        const { username, password } = config.body
        if (password !== '123456') {
            return {
                code: 500,
                message: '用户名密码错误'
            }
        }

        const token = tokens[username]

        if (!token) {
            return {
                code: 500,
                message: '用户名密码错误'
            }
        }

        return {
            code: 200,
            message: 'ok',
            data: token
        }
    },
    userInfo: config => {
        const { token } = config.query
        const info = users[token]
        if (!info) {
            return {
                code: 500,
                message: '找不到该用户'
            }
        }
        return {
            code: 200,
            data: info,
            message: 'ok'
        }
    }
}